extends Node
func _ready():
	pass
func _init():
	config.bfDir["<烧蚀>"] = "每层额外降低2%护甲、承疗，最高20层，每秒减少层数"
	config.bfDir["<活力>"] = "每2秒恢复[施法者炮击雷击航空之和*(层数*0.1+0.1)]的生命值，提高[层数*1%]的射速、[层数*1%]的冷却，每秒减少层数"
	config.bfDir["<暴露>"] = "15%易伤，叠加时每次增加5%"
	config.bfDir["<无敌>"] = "免疫任何伤害，不受弱驱散效果影响"
	config.bfDir["<狂化>"] = "提高200%主炮射速"
	config.bfDir["<致盲>"] = "炮击15%概率偏离，每层额外增加2%，最高20层，每秒减少层数"
	config.bfDir["<干扰>"] = "技能伤害10%概率偏离，每层额外增加2%，最高20层，每秒减少层数"
	config.bfDir["<虚弱>"] = "炮击雷击航空降低20%，每层额外降低2%，最高20层，每秒减少层数"
	config.bfDir["<炮术>"] = "提高2点炮击，每层额外增加2点，最高40层，每秒减少层数"
	config.bfDir["<速射>"] = "提高20%射速，每层额外增加2%，最高20层，每秒减少层数"
	config.bfDir["<流血>"] = "降低5%伤害，额外受到5%伤害，每层额外增加1%，最高20层，每秒减少层数"
	config.bfDir["<灼烧>"] = "每秒受到1.5%血上限的真实伤害，每层额外提高0.1%，最高20层，每秒减少层数"
	config.bfDir["<霜冻>"] = "降低该角色[10+层数*2]%的射速、技能冷却速度，最高20层，每秒递减"
	config.bfDir["<破甲>"] = "每层降低3点护甲，每秒减少层数，最高20层"
	config.bfDir["<狂暴>"] = "提高20%暴击伤害，每层额外增加4%，最高20层，每秒减少层数"
	config.bfDir["<灵动>"] = "提高20点机动，每层额外增加3点，最高20层，每秒减少层数"
	config.bfDir["<瘫痪>"] = "三维降低50%"
	config.bfDir["<放逐>"] = "无法造成任何伤害"
	config.bfDir["<沉睡>"] = "无法行动，沉睡1秒后受到攻击则解除"
	config.bfDir["<漏水>"] = "每秒损失[2%+三攻*层数*0.0004%]的血量，最高20层，每秒减少层数。若有多个角色同时施加漏水，则伤害按照双攻最高角色来计算"
	config.bfDir["<圣盾>"] = "免疫一次炮击或雷击伤害，最多12层"
	config.bfDir["<亡语>"] = "该技能类型为亡语，会受到相关效果的影响"
	config.bfDir["<舰载机>"] = "受航母航空属性加成，继承航母的所有装备及装备属性"
	config.bfDir["<坚守>"] = "提高20%护甲，每层额外增加2%，最高20层，每秒减少层数"
	config.bfDir["<强攻>"] = "提高20%炮击雷击，每层额外增加2%，最高20层，每秒减少层数"
	config.bfDir["<速攻>"] = "提高20%炮击、射速，每层额外增加2%，最高20层，每秒减少层数"
	config.bfDir["<剧毒>"] = "炮击对自身造成[施法者双攻*层数*0.04]伤害，施放技能对自身造成炮击的双倍伤害，最高20层，每秒减少层数"
	config.bfDir["眩晕"] = "无法移动、攻击、施放技能，但技能CD会照常冷却"
	config.bfDir["<模糊>"] = "在场上有队友存活时，无法被敌人锁定为攻击目标，但也会受到溅射或强制指定目标的伤害，每秒减少层数"
	config.bfDir["潜行"] = "获得<模糊>效果，下次发动普攻时，造成3倍伤害，并失去潜行效果"
	config.bfDir["<反击>"] = "受到攻击时对攻击者立即发起一次炮击"
	config.bfDir["<振奋>"] = "提高10%炮击、雷击、航空、护甲，每层额外增加1%，最高20层，每秒减少层数"
	config.bfDir["<沉默>"] = "无法施放技能"
	config.bfDir["<重力>"] = "降低5%机动，每层额外降低2%，最高20层，每秒减少层数"
	config.bfDir["<强袭号令>"] = "受到伤害提高30%，被击杀获得8金币，每秒减少层数"
	config.bfDir["<强化水侦>"] = "降低并反弹30%技能伤害，且延长施法者1秒的技能CD"
	config.bfDir["<恐惧>"] = "双速降低30%"
	config.bfDir["<龙卷风>"] = "每秒对正中心的敌人造成[航空*1]的技能伤害并赋予1秒<眩晕>，对周围两格的敌人造成[航空*0.5]的技能伤害"
	config.bfDir["<低强度>"] = "能被所有驱散效果驱散"
	config.bfDir["<中强度>"] = "只能被强驱散效果驱散"
	config.bfDir["<高强度>"] = "无法被任何驱散效果驱散"

	config.bfDir["双攻"] = "炮击与雷击之和"
	config.bfDir["三攻"] = "炮击/雷击/航空"
	config.bfDir["三维"] = "炮击、雷击、装甲"
	config.bfDir["四维"] = "炮击、雷击、装甲、航空"
	config.bfDir["<限定>"] = "本回合内仅触发一次"
	config.bfDir["<固化>"] = "不受技能冷却效果影响，也无法受到技能复制机制影响"
	config.bfDir["<唯一>"] = "无法叠加"
	config.bfDir["<先手>"] = "开局会施放一次"

	config.bfDir["航空技能伤害"] = "该伤害受航空属性加成，1点航空提高1%伤害"

	config.bfDir["炮击："] = "影响包括主炮在内的炮击伤害，每1点炮击值提高1%炮击伤害"
	config.bfDir["雷击："] = "影响包括鱼雷在内的雷击伤害，每1点雷击值提高1%雷击伤害"
	config.bfDir["航空："] = "影响航母舰载机伤害与减伤，每1点航空提高0.3%伤害，减伤：1 - 300 / (300 + 航空)"
	config.bfDir["冷却："] = "影响技能、鱼雷、舰载机起飞、导弹发射等充能速度，计算公式：技能实际冷却 = 原冷却 / (1 + 冷却速度加成)"
	config.bfDir["装甲："] = "降低所受的炮击、雷击、技能、特效伤害，后面的括号表示实际等效减伤"

	config.bfDir["侦查："] = "舰队总侦查值的高低会影响舰队整体的实力，详情见右下角[舰队属性]按钮"
	config.bfDir["防空："] = "舰队总防空值的高低会影响舰队整体应对舰载机的战斗力，详情见右下角[舰队属性]按钮"

	config.bfDir["机动："] = "影响角色闪避炮击、雷击伤害的能力，计算公式：（对雷击闪避率）1 - 100 / (100 + 机动)， 对炮击闪避率则在雷击基础上减半"
	config.bfDir["消耗："] = "角色每回合需要消耗的资源，等级越高，消耗越大"

	config.bfDir["吸血："] = "所有伤害均能触发吸血，恢复角色[伤害值*吸血]的血量，溢出的血量将以6%的比例转化为护盾"

	config.bfDir["弱驱散"] = "可以驱散低强度BUFF，如狂怒、急速等等"
	config.bfDir["强驱散"] = "可以驱散除高强度之外的所有BUFF，如无敌、圣盾等等"
	
	config.bfDir["彻底死亡时"] = "该角色真正阵亡，即不触发任何复活机制的死亡，也不能被亡语技能触发"
	
	call_deferred("azurlaneInit")

func _connect():
	pass
var relic
func azurlaneInit():
	relic = globalData.infoDs["g_azurlaneRelic"]

#添加漏水BUFF
func addLouShui(target, caster, lv):
	var buff = target.hasBuff("b_louShui")
	if buff == null:
		caster.castBuff(target, b_louShui.new(lv))
	elif caster.att.atk + caster.att.mgiAtk + caster.att.air > buff.casCha.att.atk + buff.casCha.att.mgiAtk + buff.casCha.att.air:
		buff.casCha = caster
		buff.life += lv
	else:
		buff.life += lv

#添加圣盾
func addShengDun(target, lv):
	var buff = target.hasBuff("b_shengDun")
	if buff == null:
		target.addBuff(b_shengDun.new(lv))
	elif buff.num < 12:
		buff.num += (lv)

#随机Debuff
var debuffs = [b_shaoShi, b_shuangDong, b_zhiMang, b_louShui, b_xuRuo, b_ganRao, b_zhongLi]
func addRndDebuff(cha, target, num):
	var bf = sys.rndListItem(debuffs)
	if bf == b_louShui:
		addLouShui(target, cha, num)
	else:
		target.addBuff(bf.new(num))

#添加暴露
func addBaoLu(target, lv):
	var buff = target.hasBuff("b_baoLu")
	if buff == null:
		target.addBuff(b_baoLu.new(lv))
	else:
		buff.reset(lv)		

#添加剧毒BUFF
func addJuDu(target, caster, lv):
	var buff = target.hasBuff("b_juDu")
	if buff == null:
		caster.castBuff(target, b_juDu.new(lv))
	elif caster.att.atk + caster.att.mgiAtk > buff.casCha.att.atk + buff.casCha.att.mgiAtk:
		buff.casCha = caster
		buff.life += lv
	else:
		buff.life += lv

#添加活力BUFF
func addHuoLi(target, caster, lv):
	var buff = target.hasBuff("b_huoLi")
	if buff == null:
		caster.castBuff(target, b_huoLi.new(lv))
	elif caster.att.atk + caster.att.mgiAtk + caster.att.air > buff.casCha.att.atk + buff.casCha.att.mgiAtk + buff.casCha.att.air:
		buff.casCha = caster
		buff.life += lv
	else:
		buff.life += lv

class AzurBuff:
	extends Buff
	var utils = globalData.infoDs["g_azurlaneUtils"]
	var relic = globalData.infoDs.get("g_azurlaneRelic")
	#buff强度， 1：弱强度，2：高强度
	var dispel = 1
	var buffName = ""
	func attInit():
		att = utils.loadScript("AzurAtt")	

#难度增伤
class b_atkR_diff:
	extends AzurBuff
	func _init(num = 1.0):
		attInit()
		id = "b_atkR_diff"	
		att.atkR = 0.1 * num
		att.reHp = -0.1
		dispel = 2

#增伤
class b_atkR:
	extends AzurBuff
	func _init(num = 1.0, duration = 0, dispelable = true):
		attInit()
		buffName = "百分比增伤"
		id = "b_atkR"	
		if num < 0:
			isNegetive = true
		att.atkR = 0.1 * num
		noLife = true
		life = duration
		if duration > 0:
			noLife = false
			lv = duration
		else:
			id += "_p"
		if dispelable: self.dispel = 2

#模糊
class b_moHu:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		life = lv
		id = "b_moHu"
		buffName = "模糊"

#漏水 
var louShuiEff = "每秒损失[2%+三攻*层数*0.0003%]的血量，最高20层，每秒减少层数。若有多个角色同时施加漏水，则伤害按照三攻最高角色来计算"
class b_louShui:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		id = "b_louShui"
		life = lv
		isNegetive = true
		buffName = "漏水"
	func _upS():
		life = min(20, life)
		doDmg()
	func allDmg():
		doDmg(life)
		isDel = true
	func doDmg(times = 1):
		var rate = min(0.06, 0.000004 * (casCha.att.mgiAtk + casCha.att.atk + casCha.att.air) * life + 0.01) * pw
		var dmg = min(40000, masCha.att.maxHp) * rate * times
		if masCha.team == 1:
			dmg = min(masCha.att.maxHp * 0.05, dmg)
		if masCha.type == sys.CharaClass.BOSS:
			dmg *= 0.25
		casCha.azurHurtChara(masCha, dmg, sys.HurtType.REAL, sys.AtkType.EFF, "漏水")
		if relic.louShuiRelic:
			if masCha.type == sys.CharaClass.BOSS:
				casCha.azurHurtChara(masCha, masCha.att.maxHp * 0.01, sys.HurtType.REAL, sys.AtkType.EFF, "漏水")
			else:
				casCha.azurHurtChara(masCha, masCha.att.maxHp * 0.03, sys.HurtType.REAL, sys.AtkType.EFF, "漏水")

#烧蚀
class b_shaoShi:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		id = "b_shaoShi"	
		isNegetive = true
		life = lv
		buffName = "烧蚀"
	func _upS():
		life = min(20, life)
		att.reHp = -(0.02 * life) * pw
		att.defL = -(0.02 * life) * pw
		if relic.betterShaoShi:
			att.atkL = -(0.05 + 0.01*life*pw)
			att.mgiAtkL = -(0.05 + 0.01*life*pw)
			att.airL = -(0.05 + 0.01*life*pw)

#圣盾
class b_shengDun:
	extends AzurBuff
	var eff2
	var num = 0
	func _init(num = 1):
		attInit()
		id = "b_shengDun"
		self.num = num
		buffName = "圣盾"
		dispel = 2
	func _connect():
		masCha.connect("onHurt", self, "onHurt")
		eff2 = sys.newEff("animEff", masCha.position)
		eff2.setImgs(sys.getBasePath() + "/eff/shengDun", 5, true)
		eff2.scale *= 0.9
		eff2.normalSpr.position=Vector2(0, -50)
	func onHurt(atkInfo:AtkInfo):
		if atkInfo.hurtVal > 0 and not atkInfo.isMiss and num > 0 and (atkInfo.atkType == sys.AtkType.GUN or atkInfo.atkType == sys.AtkType.TORPEDO and num > 2):
			num -= 1
			if atkInfo.atkType == sys.AtkType.TORPEDO:
				num -= 2
			elif atkInfo.isCri:
				num -= 1
			if atkInfo.atkCha.type == sys.CharaClass.BOSS:
				num -= 1
			if num > -1:
				atkInfo.virtual = true
			if masCha.has_method("afterShengDun"):
				masCha.afterShengDun(atkInfo.atkCha)
		if num <= 0:
			isDel = true
	func _process(delta):
		if masCha != null && is_instance_valid(eff2):
			eff2.position = masCha.position
	func _del():
		._del()
		if is_instance_valid(eff2):
			eff2.queue_free()
	func _upS():
		num = min(12, num)		

#炮术
class b_paoShu:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		life = lv
		id = "b_paoShu"
		buffName = "炮术"
	func _upS():
		life = min(40, life)
		att.atk = ( 2 + life * 2 ) * pw

#坚守
class b_jianShou:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		life = lv
		id = "b_jianShou"
		buffName = "坚守"
	func _upS():
		life = min(20, life)
		att.defL = ( 0.2 + life * 0.02 ) * pw

#强攻
class b_qiangGong:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		life = lv
		id = "b_qiangGong"
		buffName = "强攻"
	func _upS():
		life = min(20, life)
		att.mgiAtkL = ( 0.2 + life * 0.02 ) * pw
		att.atkL = ( 0.2 + life * 0.02 ) * pw

#振奋
class b_zhenFen:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		life = lv
		id = "b_zhenFen"
		buffName = "振奋"
	func _upS():
		life = min(20, life)
		att.defL = ( 0.1 + life * 0.01 ) * pw
		att.atkL = ( 0.1 + life * 0.01 ) * pw
		att.mgiAtkL = ( 0.1 + life * 0.01 ) * pw
		att.airL = ( 0.1 + life * 0.01 ) * pw

#速攻
class b_suGong:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		life = lv
		id = "b_suGong"
		buffName = "速攻"
	func _upS():
		life = min(20, life)
		att.atk = (2 + life * 2) * pw
		att.spd = (0.2 + life * 0.02) * pw

#灵动
class b_lingDong:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		life = lv
		id = "b_lingDong"
		buffName = "灵动"
	func _upS():
		life = min(20, life)
		att.dod = (20 + life * 3) * pw

#破甲
class b_poJia:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		life = lv
		id = "b_poJia"
		buffName = "破甲"
		isNegetive = true
	func _upS():
		life = min(20, life)
		att.def = -(3 + life * 3) * pw

#流血
class b_liuXueR:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		life = lv
		id = "b_liuXueR"
		buffName = "流血"
		isNegetive = true
	func _upS():
		life = min(20, life)
		att.defR = -(0.05 + life * 0.01) * pw
		att.atkR = -(0.05 + life * 0.01) * pw

#虚弱
class b_xuRuo:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		life = lv
		id = "b_xuRuo"
		buffName = "虚弱"
		isNegetive = true
	func _upS():
		life = min(20, life)
		att.atkL = -(0.2 + life * 0.02) * pw
		att.mgiAtkL = -(0.2 + life * 0.02) * pw
		att.airL = -(0.2 + life * 0.02) * pw

#重力
class b_zhongLi:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		life = lv
		id = "b_zhongLi"
		buffName = "重力"
		isNegetive = true
	func _upS():
		life = min(20, life)
		att.dod = -(0.05 + life * 0.02) * pw

#狂化
class b_kuangHua:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		life = lv
		id = "b_kuangHua"
		buffName = "狂化"
		att.spd = 2

#灼烧
class b_zhuoShao:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		life = lv
		id = "b_zhuoShao"
		isNegetive = true
		buffName = "灼烧"
	func _upS():
		life = min(20, life)
		var dmg = masCha.att.maxHp * (0.015 + life * 0.001)
		if masCha.type == sys.CharaClass.BOSS:
			casCha.azurHurtChara(masCha, dmg*0.25, sys.HurtType.REAL,sys.AtkType.EFF, "烧灼")
		else:
			casCha.azurHurtChara(masCha, dmg, sys.HurtType.REAL,sys.AtkType.EFF, "烧灼")
		
#变更承伤（乘算）
class b_hurtVal:
	extends AzurBuff
	var num = 1
	func _init(num = 1, duration = 0, disp = false):
		attInit()
		buffName = "变更承伤率（乘算）"
		dispel = 1
		id = "b_hurtVal"
		self.num = num
		if num > 1:
			isNegetive = true
		if duration > 0:
			life = duration
		else:
			id += "_p"
		if disp:
			id += "_d"
			if disp:
				self.dispel = 2
	func _connect():
		masCha.connect("onHurt",self,"_onHurt")
	func _onHurt(atkInfo:AtkInfo):
		if atkInfo.hurtVal > 0 && not atkInfo.isMiss:
			atkInfo.hurtVal *= num

#装甲-固定数值
class b_def:
	extends AzurBuff
	func _init(num = 1, duration = 0, disp = false):
		attInit()
		buffName = "变更装甲-固定数值"
		dispel = 1
		id = "b_def"
		att.def = num
		if num < 0:
			isNegetive = true
		if duration > 0:
			life = duration
		else:
			id += "_p"
		if disp:
			id += "_d"
			if disp:
				self.dispel = 2

#眩晕
class b_xuanYun:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		id = "b_xuanYun"
		life = lv
		isNegetive=true
		buffName = "眩晕"
	var eff2
	func _connect():
		._connect()
		if masCha.type == sys.CharaClass.BOSS:
			life *= 0.5
		masCha.aiOn = false
		masCha.enableCastSkill = false
		eff2 = sys.newEff("animEff", masCha.position)
		eff2.setImgs(sys.getBasePath() + "/eff/yunXuan", 5, true)
		eff2.scale *= 1
		eff2.normalSpr.position=Vector2(0, -70)
	func _del():
		._del()
		masCha.aiOn = true
		masCha.enableCastSkill = true
		if is_instance_valid(eff2):
			eff2.queue_free()
	func _process(delta):
		if masCha != null && is_instance_valid(eff2):
			eff2.position = masCha.position
	func _upS():
		life = min(15, life)

		
#霜冻
class b_shuangDong:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		id = "b_shuangDong"	
		isNegetive = true
		life = lv
		buffName = "霜冻"
	func _upS():
		life = min(20, life)
		att.spd = -(0.1+0.02*life*pw)
		att.cd = -(0.1+0.02*life*pw)
		if relic.betterFreeze:
			att.atkL = -(0.05 + 0.01*life*pw)
			att.mgiAtkL = -(0.05 + 0.01*life*pw)
			att.airL = -(0.05 + 0.01*life*pw)
		
#致盲
class b_zhiMang:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		id = "b_zhiMang"
		life = lv
		isNegetive = true
		buffName = "致盲"
	func _connect():
		masCha.connect("onAtkChara",self,"_onAtkChara")
	func _onAtkChara(atkInfo:AtkInfo):
		if atkInfo.atkType == sys.AtkType.GUN and sys.rndPer((15 + life * 2)*pw):
			atkInfo.isMiss = true
			atkInfo.atkType = sys.AtkType.MISS

#干扰
class b_ganRao:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		id = "b_ganRao"
		life = lv
		isNegetive = true
		buffName = "干扰"
	func _connect():
		masCha.connect("onAtkChara",self,"_onAtkChara")
	func _onAtkChara(atkInfo:AtkInfo):
		if atkInfo.atkType == sys.AtkType.SKILL and sys.rndPer((10 + life * 2)*pw):
			atkInfo.isMiss = true
			atkInfo.atkType = sys.AtkType.MISS

#暴露
class b_baoLu:
	extends AzurBuff
	var p1 = 0
	var p2 = 1
	func reset(num):
		p1 += num
		p2 = 1 + (p1 * 0.1)
	func _init(num = 1):
		attInit()
		id = "b_baoLu"
		reset(num)
		isNegetive = true
		buffName = "暴露"
	func _connect():
		masCha.connect("onHurt",self,"onHurt")
	func onHurt(atkInfo):
		if atkInfo.hurtVal > 0:
			atkInfo.factor += (p2 - 1)

#斩杀
class b_zhanSha:
	extends AzurBuff
	func _init(lv = 0):
		attInit()
		dispel = 2
		id = "b_zhanSha"
		if lv > 0:
			life = lv
	func _connect():
		masCha.connect("onAtkChara",self,"run")
	func run(atkInfo):
		if atkInfo.atkType == sys.AtkType.GUN and atkInfo.hitCha.att.hp/atkInfo.hitCha.att.maxHp <= 0.20:
			atkInfo.hurtVal = 0
			masCha.utils.createSkillTextEff("斩杀", masCha.position)
			atkInfo.hitCha.forceHurtSelf(atkInfo.hitCha.att.maxHp)
			masCha.increDmgNum(atkInfo.hitCha.att.hp, "斩杀", atkInfo.hitCha)			

#双速
class b_twoSpd:
	extends AzurBuff
	func _init(num = 1.0, duration = 0):
		attInit()
		buffName = "双速"
		id = "b_twoSpd"	
		if num < 0:
			isNegetive = true
		att.spd = 0.1 * num
		att.cd = 0.1 * num
		if duration > 0:
			life = duration
			lv = duration
		else:
			id += "_p"

#嘲讽
class b_chaoFeng:
	extends AzurBuff
	func _init(lv = 1):
		buffName = "被嘲讽"
		life = lv
		isNegetive = true
		id = "b_chaoFeng"
	func _del():
		masCha.aiCha = null
		._del()
	func _upS():
		life = min(20, life)
		if casCha.isDeath:
			isDel = true
		elif masCha.aiCha != casCha:
			masCha.aiCha = casCha

#反召唤物
class b_antiSumm:
	extends AzurBuff
	var num = 1
	func _init(num = 1):
		attInit()
		buffName = "反召唤物"
		id = "b_antiSumm"
		self.num = 1 + 0.1*num
		dispel = 2
	func _connect():
		masCha.connect("onAtkChara",self,"_onAtkChara")
	func _onAtkChara(atkInfo:AtkInfo):
		if atkInfo.hurtVal > 0 && atkInfo.hitCha.isSumm:
			atkInfo.hurtVal *= num

#燃烧弹
class b_heAmmo:
	extends AzurBuff
	func _init():
		attInit()
		id = "b_heAmmo"
		life = 4
		buffName = "燃烧弹"
		dispel = 2
	func _connect():
		._connect()
		att.reHp = -0.6

#剧毒
class b_juDu:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		id = "b_juDu"
		life = lv
		isNegetive = true
		buffName = "剧毒"
	func _connect():
		masCha.connect("onAtkChara",self,"_onAtkChara")
		masCha.connect("onCastCdSkill",self,"onCastCdSkill")
	func _upS():
		life = min(20, life)
	func _onAtkChara(atkInfo:AtkInfo):
		if atkInfo.atkType == sys.AtkType.GUN:
			if not casCha.isDeath:
				casCha.azurHurtChara(masCha, (casCha.att.atk + casCha.att.mgiAtk)*life*0.04, sys.HurtType.WEAPON, sys.AtkType.EFF, "剧毒")
			else:
				masCha.azurHurtChara(masCha, (casCha.att.atk + casCha.att.mgiAtk)*life*0.04, sys.HurtType.WEAPON, sys.AtkType.EFF, "剧毒-自残")
	func onCastCdSkill(id):
		if not casCha.isDeath:
			casCha.azurHurtChara(masCha, (casCha.att.atk + casCha.att.mgiAtk)*life*0.08, sys.HurtType.WEAPON, sys.AtkType.EFF, "剧毒")
		else:
			masCha.azurHurtChara(masCha, (casCha.att.atk + casCha.att.mgiAtk)*life*0.08, sys.HurtType.WEAPON, sys.AtkType.EFF, "剧毒-自残")

#承疗
class b_reHp:
	extends AzurBuff
	func _init(num = 1.0, duration = 0):
		attInit()
		id = "b_reHp"	
		if num < 0:
			isNegetive = true
		att.reHp = 0.1 * num
		buffName = "承疗"
		if duration > 0:
			life = duration
		else:
			id += "_p"

#闪避
class b_dod:
	extends AzurBuff
	func _init(num = 1, duration = 0):
		attInit()
		buffName = "闪避"
		id = "b_dod"	
		if num < 0:
			isNegetive = true
		att.dod = num
		if duration > 0:
			life = duration
		else:
			id += "_p"

#无敌
class b_wudi:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		life = lv
		id = "b_wudi"
		buffName = "无敌"
		dispel = 2
	func _connect():
		masCha.connect("onHurt",self,"_onHurt")
	func _onHurt(atkInfo:AtkInfo):
		if atkInfo.hurtVal > 0 && not atkInfo.isMiss:
			atkInfo.hurtVal = 0
	func _upS():
		life = min(10, life)

#活力
class b_huoLi:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		id = "b_huoLi"
		life = lv
		buffName = "活力"
		dispel = 2
	var index = 0
	func _upS():
		life = min(20, life)
		att.spd = 0.01 * life * pw
		att.cd = 0.01 * life * pw
		index += 1
		if index >= 2:
			index = 0
			casCha.healCha(masCha, (casCha.att.mgiAtk+casCha.att.atk+casCha.att.air)*(life*0.1 + 0.1) * pw)

#免疫负面效果
class b_mianYi:
	extends AzurBuff
	func _init(lv = 0):
		attInit()
		id = "b_mianYi"
		buffName = "免疫负面效果"
		dispel = 2
		if lv > 0:
			life = lv
	func _connect():
		masCha.connect("onAddBuff",self,"onAddBuff")
	func onAddBuff(buff):
		if buff.isNegetive and buff.dispel == 1:
			buff.isDel = true
#射程
class b_atkRan:
	extends AzurBuff
	func _init(num = 1, duration = 0, dispel = 1):
		attInit()
		buffName = "射程"
		id = "b_atkRan"	
		if num < 0:
			isNegetive = true
		att.atkRan = num
		if duration > 0:
			life = duration
		else:
			id += "_p"
		dispel = dispel	

#反击
class b_fanJi:
	extends AzurBuff
	#反击概率，不可太高，减少套娃
	var r = 30
	func _init(lv = 1, r = 30):
		attInit()
		id = "b_fanJi"
		life = lv
		self.r = r
		buffName = "反击"
		dispel = 2
	func _connect():
		._connect()
		masCha.connect("onHurt", self, "onHurt")
	func onHurt(atkInfo:AtkInfo):
		if atkInfo.atkType != sys.AtkType.EFF and sys.rndPer(r) and atkInfo.atkCha.hasBuff("b_fanJi") == null and atkInfo.atkCha.team != masCha.team:
			masCha.normalAtkChara(atkInfo.atkCha)

#冷却
class b_cd:
	extends AzurBuff
	func _init(num = 1.0, duration = 0):
		attInit()
		buffName = "冷却速度"
		id = "b_cd"	
		if num < 0:
			isNegetive = true
		att.cd = 0.1 * num
		if duration > 0:
			life = duration
			lv = duration
		else:
			id += "_p"

#放逐
class b_fangZhu:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		id = "b_fangZhu"
		life = lv
		isNegetive = true
		buffName = "放逐"
	func _connect():
		masCha.connect("onAtkChara",self,"_onAtkChara")
	func _onAtkChara(atkInfo):
		atkInfo.virtual = true
		atkInfo.hurtVal = 0

#禁足
class b_jinZu:
	extends AzurBuff
	func _init(lv = 1):
		attInit()
		id = "b_jinZu"
		life = lv
		isNegetive = true
		buffName = "禁足"
	func _connect():
		masCha.moveSpeed = 0
	func _del():
		masCha.moveSpeed = config.defaultMoveSpd
		._del()

#攻速
class b_spd:
	extends AzurBuff
	func _init(num = 1.0, duration = 0, disp = 1):
		attInit()
		buffName = "攻速"
		id = "b_spd"	
		dispel = disp
		if dispel == 2:
			id += "_d"
		if num < 0:
			isNegetive = true
		att.spd = 0.1 * num
		if duration > 0:
			life = duration
			lv = duration
		else:
			id += "_p"

#暴击
class b_cri:
	extends AzurBuff
	func _init(num = 1.0, duration = 0):
		attInit()
		buffName = "暴击"
		id = "b_cri"	
		if num < 0:
			isNegetive = true
		att.cri = 0.1 * num
		if duration > 0:
			life = duration
			lv = duration
		else:
			id += "_p"

#沉睡
class b_chenShui:
	extends AzurBuff
	var eff2
	func _init(lv = 1):
		attInit()
		id = "b_chenShui"
		life = lv
		isNegetive = true
		buffName = "沉睡"
	func _connect():
		._connect()
		masCha.aiOn = false
		masCha.enableCastSkill = false
		masCha.connect("onHurt", self, "onHurt")
		eff2 = sys.newEff("animEff", masCha.position)
		eff2.setImgs(sys.getBasePath() + "/eff/sleep", 6, true)
		eff2.scale *= 0.8
		eff2.normalSpr.position=Vector2(0, -10)
	func onHurt(atkInfo:AtkInfo):
		life = 0
		isDel = true
	func _del():
		._del()
		masCha.aiOn = true
		masCha.enableCastSkill = true
		if is_instance_valid(eff2):
			eff2.queue_free()
	func _process(delta):
		if masCha != null && is_instance_valid(eff2):
			eff2.position = masCha.position
#反伤
class b_fanShang:
	extends AzurBuff
	var num = 0
	func _init(num = 0, duration = 0):
		attInit()
		id = "b_fanShang"
		self.num = num
		if duration > 0:
			life = duration
			lv = duration
		else:
			id += "_p"
	func _connect():
		masCha.connect("onHurt", self, "onHurt")
	func onHurt(atkInfo):
		if atkInfo.atkType != sys.AtkType.EFF and atkInfo.hurtVal > 0 and not atkInfo.virtual and atkInfo.atkCha.team != masCha.team:
			atkInfo.fanShang += num
